define(function(require){
	var main =require('/static/main.js');
	var m = new main();
	function Cont(){
		this.Fun._init();
	}
	Cont.prototype.Fun = {
		_init:function(){
			$('.q-tit-change a').attr('href',"/drainage/turnplatetracking?id="+$_GET['parid']);
		    m.loadmenu('.cate-drainage',4);
		    this.getlist();
			this.bindEvent();
		},
		bindEvent:function(){
			
		},
		getlist:function(){
	        var param = {};
	        var sort = 0;
	        var table1 = $('#datatable').dataTable({
	        	'ordering':false,
	        	"serverSide": true,
	        	"searching":false,
	        	'bLengthChange': false,
	        	"scrollX": true,
	        	ajax: function (data, callback, settings) {
	                param.PageSize = data.length;
	                param.start = data.start;
	                param.PageNo = (data.start / data.length)+1;
	                param.RecordId = $_GET['id'];
	                $.ajax({
	                    type: "POST",
	                    url: "/drainage/turnplaterecord-join-list",
	                    cache: false,  
	                    data: param, 
	                    dataType: "json",
	                    success: function (result) {
                    	    var returnData = {};
                            returnData.draw = data.draw;
                            returnData.recordsTotal = result.total;
                            returnData.recordsFiltered = result.total;
                            returnData.data = result.data;
                            callback(returnData);
	                    }
	                });
	            },
				"aoColumns":[
					{
						"mDataProp": 'ReceiveRecordId',
						render:function(data){
							sort ++;
                    		return sort;
                    	}
					}, 
					{"mDataProp": "PrizeName"},
					{
						"mDataProp": 'PrizeSrc',
						"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
							$(nTd).html('<img src="'+sData+'" onerror="this.src=\'/modules/img/default.jpg\'" style="width:50px;">')
			            }
					},
                    {
                        "mDataProp": 'CreateTime',
                        render:function(data){
                            if(data){
                                return m.formatTimeAll2(data)
                            }else{
                                return '';
                            }
                        }
                    },
				],
	        }).api();
			// 点击搜索
	        $('#btnSearch').click(function(){
	        	param.StartTime = $('.StartTime').val()
	        	param.EndTime = $('.EndTime').val()
	        	param.Nickname = $('.Nickname').val()
	        	param.Phone = $('.Phone').val()
	        	sort = 0;
                table1.ajax.reload();
	        })
	        // 点击重置按钮
	        $('#btnRefresh').click(function(){
	        	$('.StartTime').val('');
	        	$('.EndTime').val('');
	        	$('.Nickname').val('');
	        	$('.Phone').val('');
                param.StartTime = '';
                param.EndTime = '';
                param.Nickname = '';
                param.Phone = '';
                var table = $('#datatable').DataTable();
                table.ajax.reload();
	        })
		},

	}
	var a = new Cont();

})